package com.demo.datastructure.reorder.selectorSort;

import com.demo.datastructure.reorder.Example;

/**
 * @description: 选择排序
 * @author: ljr
 * @time: 2021/8/29 16:49
 */
public class SimpSelectorSort implements Example {

    @Override
    public void sort(Comparable[] a) {
        int n = a.length;
        for(int i = 0; i < n-1; i++){
            //Comparable min = a[i];
            int min = i;
            for(int l = i+1; l < n; l++){
               if(less(a[l], a[min]))
                   min = l;

               /* if(a[l].compareTo(min) < 0){
                    minIndex = l;
                    min = a[l];
                }*/
            }
            exch(a, i, min);
            /*a[minIndex] = a[i];
            a[i] = min;*/
        }
    }
}
